import request from '@/utils/request'

enum api {
  roleList = '/admin/acl/role/',
  save = '/admin/acl/role/save',
  update = '/admin/acl/role/update',
  delete = '/admin/acl/role/remove/',
  menuList = '/admin/acl/permission/toAssign/',
  updateMenu = '/admin/acl/permission/doAssignAcl',
}

export const reqRoleList = (page: any, limit: any, roleName: any) =>
  request.get(api.roleList + `${page}/${limit}?roleName=${roleName}`)
export const reqSaveOrUpdate = (data: any) => {
  if (data.id) {
    return request.put(api.update, data)
  } else {
    return request.post(api.save, data)
  }
}
export const reqRemove = (data: any) => request.delete(api.delete + data)

export const reqMenuList = (data: any) => request.get(api.menuList + data)

export const reqUpdateMenu = (data: any) => request.post(api.updateMenu, data)
